﻿
namespace Mulala.Cavan.Core.Persistent
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics.Contracts;
    using System.Linq;

    /// <summary>
    ///     ISearch extended with position list (for row paging) and switch for paging buttons
    /// </summary>
    /// <typeparam name = "TID"></typeparam>
    public interface ISearch<TID> : ISearch
    {
    }

    /// <summary>
    ///     Basic interface for searching object
    /// </summary>
    public interface ISearch
    {
        /// <summary>
        ///     DO NOT FILL !!!
        ///     Dao will fill this value. 
        ///     Total count of all rows matching searching criteria.
        ///     DO NOT USE !!!
        /// </summary>
        long TotalRowCount { get; set; }

        /// <summary>
        ///     SET Maximum rows count on a page. 
        ///     In fact this value is always set, by default to 20.
        ///     In cases when the target is to find any - set it to 1.
        ///     When you want all records, set it to int.MaxValue
        /// </summary>
        int MaxRowsPerPage { get; set; }

        /// <summary>
        ///     Paging. This value is maintained by base controller
        ///     and keeps information about which is the currently navigated page
        /// </summary>
        int CurrentPage { get; set; }

        /// <summary>
        ///     Keeps the current Item number (position in the list)
        ///     to allow paging base on single Item!
        /// </summary>
        int CurrentRow { get; set; }

        /// <summary>
        ///     The counted value! Allows to display on UI how many pages is in the storage
        /// </summary>
        long PageCount { get; }

        /// <summary>
        ///     Tricky collection allowing sorting. 
        ///     If the implementing collection is Dictionary<string, bool> 
        ///                                                     then even the position plays role.
        ///                                                     The first added as firstly evaluated in the ORDER BY clause.
        /// </summary>
        IDictionary<string, bool> OrderBy { get; set; }
    }
}